const mongoose = require('mongoose')

const HOST = '119.91.126.241'
const PORT = 27017
const USERNAME = 'young'
const PASSWORD = '20001106'

const CONNECT_STRING = `mongodb://${USERNAME}:${PASSWORD}@${HOST}:${PORT}/`

module.exports = () => {
	mongoose
		.connect(CONNECT_STRING, {
			useNewUrlParser: true,
			dbName: 'competition',
		})
		.then(() => {
			console.log('连接数据库成功')
		})
		.catch(err => {
			console.error('数据库连接失败', err)
		})
}
